<template>
  <div class="food">
    <food-header/>
    <food-logo/>
    <food-swiper :list="FoodIconList"/>
    <food-recommend :list="foodRecommendList "/>
    <food-footer/>
  </div>
</template>

<script>
import FoodHeader from "./components/FoodHeader.vue";
import FoodLogo from "./components/FoodLogo.vue";
import FoodSwiper from "./components/FoodSwiper.vue";
import FoodRecommend from "./components/FoodRecommend.vue";
import FoodFooter from "./components/FoodFooter.vue";
import axios from "axios";
export default {
  name: "food",
  components: {
    FoodHeader,
    FoodLogo,
    FoodSwiper,
    FoodRecommend,
    FoodFooter
  },
  data: function() {
    return {
      FoodIconList: [],
      foodRecommendList: []
    };
  },
  mounted() {
    this.getHomeApiInfo();
  },
  methods: {
    getHomeApiInfo() {
      axios
        .get("/mock/food.json")
        .then(this.getHomeResponseInfo, function(success) {
          console.log("请求json数据成功");
          console.log(success);
        })
        .catch(function(err) {
          console.log("请求json数据失败");
          console.log(err);
        });
    },
    getHomeResponseInfo(response) {
      console.log(response.data);
      let res = response.data;
      if (res.success && res.dataList) {
        const foodData = res.dataList;
        this.FoodIconList = foodData.FoodIconLists;
        this.foodRecommendList = foodData.FoodRecommedLists;
      }
    }
  }
};
</script>          